package com.java.zhuiyun.api.member_manager.mapper;

import com.java.zhuiyun.api.member_manager.entity.MemberType;
import com.java.zhuiyun.api.member_manager.model.MemberTypeModel;
import com.java.zhuiyun.common.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @InterfaceName MemberTypeMapper
 * @Description TODO
 * @Author WX
 * @Date 2023/8/14 19:52
 **/
@Mapper
public interface MemberTypeMapper extends BaseMapper<MemberType> {
    /*
     * @Author WX
     * @Description TODO 查询所有类型 无查询条件
     * @Date 2023/8/14 19:50
     * @Return
     * @param MemberType,PageRequest
     */
    @Select("select * from member_type where del_flag=0")
    List<MemberTypeModel> selectMemberType(MemberType memberType);

    /*
     * @Author WX
     * @Description TODO 查询一条类型数据
     * @Date 2023/8/14 19:22
     * @Return
     * @param id
     */
    @Select("select * from member_type where id=#{id}")
    MemberType fingById(Integer id);

    /*
     * @Author WX
     * @Description TODO 修改状态
     * @Date 2023/8/14 19:22
     * @Return
     * @param memberType
     */
    @Update("UPDATE member_type SET is_disable = #{isDisable} WHERE id = #{id}")
    int updateModify(MemberType memberType);

    /*
     * @Author WX
     * @Description TODO 修改类型
     * @Date 2023/8/14 19:22
     * @Return
     * @param memberType
     */
    @Update("UPDATE member_type SET member_name = #{memberName}, duration = #{duration}, price = #{price}, " +
            "discount = #{discount}, member_scope = #{memberScope}, member_url = #{memberUrl}, " +
            "privilege = #{privilege}, " +
            " update_time = #{updateTime} WHERE id = #{id}")
    int updateMemberType(MemberType memberType);

    /*
     * @Author WX
     * @Description TODO 添加类型
     * @Date 2023/8/14 19:22
     * @Return
     * @param memberType
     */
    @Insert("INSERT INTO member_type (member_name, duration, price, discount, member_scope, member_url, privilege,create_time, update_time) " +
            "VALUES (#{memberName}, #{duration}, #{price}, #{discount}, #{memberScope}, #{memberUrl}, #{privilege}, #{createTime}, #{updateTime})")
    int addMemberType(MemberType memberType);

    /*
     * @Author WX
     * @Description TODO 删除类型
     * @Date 2023/8/14 19:22
     * @Return
     * @param id
     */
    @Update("update member_type set del_flag = 1 where  id = #{id}")
    int deleteById(Integer id);

    /*
     * @Author WX
     * @Description TODO 查询所有类型 模糊查
     * @Date 2023/8/14 19:50
     * @Return
     * @param MemberType,PageRequest
     */
    @Select("SELECT * FROM member_type WHERE del_flag = 0 AND member_name LIKE CONCAT('%', #{memberName}, '%')")
    List<MemberTypeModel> selectMoHuMemberType(MemberType memberType);

    /*
     * @Author WX
     * @Description TODO 查询所有类型
     * @Date 2023/8/14 19:50
     * @Return
     * @param MemberType,PageRequest
     */
    @Select("SELECT * FROM  member_type WHERE id != 4 AND del_flag != 1 AND is_disable != 1 ")
    List<MemberType> getMemberList();

    /*
     * @Author WX
     * @Description pc端查询会员类型
     * @Date 2023/8/30 10:09
     * @Return
     * @param null
     */
    @Select("SELECT * FROM  member_type WHERE id != 4 AND del_flag != 1 AND is_disable != 1")
    List<MemberType> selectMemberList();
}
